package ecs.core;

import ecs.net.EventType;

import java.util.ArrayList;
import java.util.List;

public class Scene implements IScene{

    private final List<IEntity> entities;

    private final List<ISystem> systems;


    public Scene()
    {
        entities = new ArrayList<>();
        systems = new ArrayList<>();
    }

    @Override
    public void add(ISystem system) {
        systems.add(system);
        system.parent(this);
        system.start();
    }

    @Override
    public void remove(ISystem system) {
        systems.remove(system);
        system.stop();
        system.parent(null);
    }

    @Override
    public void broadcast(EventType event, Object param) {
        systems.forEach(system -> {
            system.handle(event, param);
        });
    }

    @Override
    public void in(IEntity entity) {
        broadcast(EventType.EntityIn, entity);
    }

    @Override
    public void out(IEntity entity) {
//        systems.forEach(system -> {
//            system.quit(entity);
//        });
    }
}
